﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AD.BLL;
using AD.Model;
public partial class Manager_User_PageData_Hepler : WebManagerForm
{
    public HeplerMod hepler = new HeplerMod();
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["action"];
        if (!string.IsNullOrEmpty(action))
        {
            if (action.Equals("edit"))
            {
                string idstr = Request.QueryString["id"];
                if (!Page.IsPostBack)
                {
                    HeplerMod tmp = HeplerBLL.QueryById(idstr);
                    if (tmp != null)
                    {
                        hepler = tmp;
                    }
                }
                else
                {
                    HeplerMod tmp = HeplerBLL.QueryById(idstr);
                    if (tmp != null)
                    {
                        tmp.Title = Request.Params["title"];
                        tmp.Content = Request.Params["content"];
                        tmp.Url = Request.Params["heplerurl"];
                        hepler = tmp;
                        int effect = HeplerBLL.Update(tmp);
                        if (effect > 0)
                        {
                            Alert("修改帮助成功!");
                            RedirectNewURL("HeplerList.aspx?action=gopage&pageIndex=1");
                        }
                        else
                            Alert("修改帮助失败!");
                    }
                }
            }
            if (action.Equals("add"))
            {

                if (Page.IsPostBack)
                {
                    HeplerMod tmp = new HeplerMod();
                    tmp.Title = Request.Params["title"];
                    tmp.Content = Request.Params["content"];
                    tmp.Url = Request.Params["heplerurl"];
                    int effect = HeplerBLL.Insert(tmp);
                    hepler = tmp;
                    if (effect > 0)
                    {
                        Alert("增加帮助成功!");
                        RedirectNewURL("HeplerList.aspx?action=gopage&pageIndex=1");
                    }
                    else
                        Alert("增加帮助失败!");
                }
            }
        }
    }
}